# CMake 最低版本号要求
cmake_minimum_required (VERSION 2.8)
# 项目信息
project (utitl)

set (CMAKE_INSTALL_PREFIX /opt/ECG)
INCLUDE_DIRECTORIES(/opt/ECG/include)

if(INSTALL_HEAD_FILE_ONLY)

message(STATUS "just install head files...")

install(FILES inc/logger.h  DESTINATION include/utitl)
install(FILES inc/thread.h  DESTINATION include/utitl)

else(INSTALL_HEAD_FILE_ONLY)
message(STATUS "compile project...")

set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -DBOOST_LOG_DYN_LINK -rdynamic -std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall -DBOOST_LOG_DYN_LINK -rdynamic -std=c++11")

set(BOOST_LIB_DIR /usr/local/lib/boost)

find_library(boost_atomic libboost_atomic.so ${BOOST_LIB_DIR})
find_library(boost_chrono libboost_chrono.so ${BOOST_LIB_DIR})
find_library(boost_container libboost_container.so ${BOOST_LIB_DIR})
find_library(boost_coroutine libboost_coroutine.so ${BOOST_LIB_DIR})
find_library(boost_context libboost_context.so ${BOOST_LIB_DIR})
find_library(boost_date_time libboost_date_time.so ${BOOST_LIB_DIR})
find_library(boost_filesystem libboost_filesystem.so ${BOOST_LIB_DIR})
find_library(boost_graph libboost_graph.so ${BOOST_LIB_DIR})
find_library(boost_iostreams libboost_iostreams.so ${BOOST_LIB_DIR})
find_library(boost_locale libboost_locale.so ${BOOST_LIB_DIR})
find_library(boost_log_setup libboost_log_setup.so ${BOOST_LIB_DIR})
find_library(boost_log libboost_log.so ${BOOST_LIB_DIR})
find_library(boost_math_c99f libboost_math_c99f.so ${BOOST_LIB_DIR})
find_library(boost_math_c99l libboost_math_c99l.so ${BOOST_LIB_DIR})
find_library(boost_math_c99 libboost_math_c99.so ${BOOST_LIB_DIR})
find_library(boost_math_tr1f libboost_math_tr1f.so ${BOOST_LIB_DIR})
find_library(boost_math_tr1 libboost_math_tr1.so ${BOOST_LIB_DIR})
find_library(boost_prg_exec_monitor libboost_prg_exec_monitor.so ${BOOST_LIB_DIR})
find_library(boost_program_options libboost_program_options.so ${BOOST_LIB_DIR})
find_library(boost_random libboost_random.so ${BOOST_LIB_DIR})
find_library(boost_regex libboost_regex.so ${BOOST_LIB_DIR})
find_library(boost_serialization libboost_serialization.so ${BOOST_LIB_DIR})
find_library(boost_signals libboost_signals.so ${BOOST_LIB_DIR})
find_library(boost_stacktrace_addr2line libboost_stacktrace_addr2line.so ${BOOST_LIB_DIR})
find_library(boost_stacktrace_basic libboost_stacktrace_basic.so ${BOOST_LIB_DIR})
find_library(boost_system libboost_system.so ${BOOST_LIB_DIR})
find_library(boost_thread libboost_thread.so ${BOOST_LIB_DIR})
find_library(boost_timer libboost_timer.so ${BOOST_LIB_DIR})
find_library(boost_type_erasure libboost_type_erasure.so ${BOOST_LIB_DIR})
find_library(boost_unit_test_framework libboost_unit_test_framework.so ${BOOST_LIB_DIR})
find_library(boost_wave libboost_wave.so ${BOOST_LIB_DIR})
find_library(boost_wserialization libboost_wserialization.so ${BOOST_LIB_DIR})

set(THREAD src/thread.cpp)
set(LOGGER src/logger.cpp)

add_library(log SHARED ${LOGGER})

add_library(thread SHARED ${THREAD})

target_link_libraries(log pthread ${boost_log} ${boost_system} ${boost_thread})
target_link_libraries(thread pthread)

install(TARGETS log DESTINATION  lib)
install(TARGETS thread DESTINATION  lib)

endif(INSTALL_HEAD_FILE_ONLY)

